let provinceArray = [{id:1,name:"四川省"},{id:2,name:"云南省"},{id:3,name:"贵州省"}];
let cityArray = [{id:1,name:"贵阳",proviceId:3},{id:2,name:"遵义",proviceId:3},{id:3,name:"安顺",proviceId:3},
    {id:4,name:"昆明",proviceId:2},{id:5,name:"大理",proviceId:2},
    {id:6,name:"成都",proviceId:1},{id:7,name:"德阳",proviceId:1},{id:8,name:"绵阳",proviceId:1}];

let provinceObj,cityObj;
window.onload = function () {
    provinceObj = document.getElementById("provinceSelect");
    cityObj = document.getElementById("citySelect");

    let info = "<option value=''>请选择省份</option>";
    for(let i=0;i<provinceArray.length;i++){
        let pro = provinceArray[i];
        info += `<option value="${pro.id}">${pro.name}</option>`;
    }
    provinceObj.innerHTML = info;

    provinceObj.onchange = function () {
        findCity(this.value);
    }
}

function  findCity(provinceId) {
    let info = "";
    for(let i=0;i<cityArray.length;i++){
        var city = cityArray[i];
        if(city.proviceId == provinceId){
            info += `<option value="${city.id}">${city.name}</option>`;
        }
    }
    cityObj.innerHTML = info;
}